www.gusucode.com > vc++ 远程控制示例源程序-源码程序 > vc++ 远程控制示例源程序-源码程序\code\PeerYouC\MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class // Download by http://www.NewXing.com #include "stdafx.h" #include "PeerYouC.h" #include "MainFrm.h" #include "PeerHostTreeView.h" #include "PeerOperatorTabCtrl.h" #include "PeerMessageListView.h" #include "searchhostdlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_COMMAND(ID_OPTION_SEARCHHOST, OnOptionSearchhost) ON_COMMAND(ID_SCREEN_FULL, OnScreenFull) ON_WM_GETMINMAXINFO() //}}AFX_MSG_MAP ON_MESSAGE(FULLSCREEN,OnFullScreen) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here m_FullScreen = FALSE; } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { cs.style|=WS_MAXIMIZE; if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { // TODO: Add your specialized code here and/or call the base class if(!m_wndSplitter.CreateStatic(this,1,2)) { TRACE("Failed to Create m_wndSplitter"); return false; } if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CPeerHostTreeView),CSize(0,0),pContext)) { TRACE("Failed to Create PeerHostTreeView!"); return false; } if(!m_wndSplitter2.CreateStatic(&m_wndSplitter,2,1,WS_CHILD|WS_VISIBLE|TCS_FLATBUTTONS,m_wndSplitter.IdFromRowCol(0,1))) { TRACE("Failed to Create PeerOperatorTabCtrl!"); return false; } if(!m_wndSplitter2.CreateView(1,0,RUNTIME_CLASS(CPeerMessageListView),CSize(0,0),pContext)) { TRACE("Failed to Create CPeerMessageListView!"); return false; } // if(!m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CPeerOperatorView),CSize(0,0),pContext)) // { // TRACE("Failed to Create CPeerOPeratorView!"); // return false; // } if(!m_wndOperatorTab.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),&m_wndSplitter2,m_wndSplitter2.IdFromRowCol(0,0))) { TRACE("Failed to Create CPeerMessageTab!"); return false; } ////////////////////////////////////////// CRect r; GetClientRect(&r); int w1 = r.Width()/10*3; int w2 = r.Width()/10*7; m_wndSplitter.SetColumnInfo( 0, w1, 0 ); m_wndSplitter.SetColumnInfo( 1, w2, 0 ); m_wndSplitter.RecalcLayout(); w1 = r.Height()/10*9; w2 = r.Height()/10; m_wndSplitter2.SetRowInfo( 0, w1, 0 ); m_wndSplitter2.SetRowInfo( 1, w2, 0 ); m_wndSplitter2.RecalcLayout(); ////////////get some info/////////// m_pTreeHost=(CPeerHostTreeView*)m_wndSplitter.GetPane(0,0); m_pListMessage=(CPeerMessageListView*)m_wndSplitter2.GetPane(1,0); return true; } void CMainFrame::OnOptionSearchhost() { // TODO: Add your command handler code here CSearchHostDlg dlgSearchHost; if(dlgSearchHost.DoModal()==IDOK) { } } void CMainFrame::OnScreenFull() { // TODO: Add your command handler code here RECT DesktopRect; WINDOWPLACEMENT WPNew; m_FullScreen = m_FullScreen ? TRUE : FALSE; if(!m_FullScreen) { // need to hide all status bars m_wndStatusBar.ShowWindow(SW_HIDE); m_wndToolBar.ShowWindow(SW_HIDE); //Adjust RECT to new size of window ::GetWindowRect(::GetDesktopWindow(), &DesktopRect); m_wndSplitter.GetPane(0,0)->ShowWindow(SW_HIDE); m_wndSplitter2.GetPane(1,0)->ShowWindow(SW_HIDE); m_wndSplitter.GetColumnInfo(0,x,x1); m_wndSplitter2.GetRowInfo(0,y,y1); CRect tabrect; CPeerOperatorTabCtrl *tabctrl; tabctrl=(CPeerOperatorTabCtrl *)m_wndSplitter2.GetPane(0,0); tabctrl->GetItemRect(0,&tabrect); // We'll need these to restore the original state. GetWindowPlacement (&m_WPPrev); m_wndSplitter.SetColumnInfo( 0,0,0); m_wndSplitter2.SetRowInfo( 0,DesktopRect.bottom-DesktopRect.top+tabrect.Height()+44,0); m_WPPrev.length = sizeof m_WPPrev; DesktopRect.left -= 1+16; DesktopRect.top -= tabrect.Height()+44; DesktopRect.bottom += 2+16; DesktopRect.right += 2+8; ::AdjustWindowRectEx(&DesktopRect, GetStyle(), TRUE, GetExStyle()); // Remember this for OnGetMinMaxInfo() m_FullScreenWindowRect = DesktopRect; WPNew = m_WPPrev; WPNew.showCmd = SW_SHOWNORMAL; WPNew.rcNormalPosition = DesktopRect; // m_pWndFullScreenBar=new CToolBar; // // if(!m_pWndFullScreenBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) || // !m_pWndFullScreenBar->LoadToolBar(IDR_SCREEN_FULL)) // { // TRACE0("Failed to create toolbar\n"); // return; // fail to create // } // // //don't allow the toolbar to dock // m_pWndFullScreenBar->ModifyStyle(WS_CAPTION,0); // m_pWndFullScreenBar->EnableDocking(0); // m_pWndFullScreenBar->SetWindowPos(0, 0,0, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW); // m_pWndFullScreenBar->SetWindowText(_T("Hold Ctrl+F to switch between normal and a full screen")); // FloatControlBar(m_pWndFullScreenBar, CPoint(0,0)); // m_pWndFullScreenBar->EnableToolTips(TRUE); m_FullScreen=TRUE; } else { // m_pWndFullScreenBar->DestroyWindow(); // delete m_pWndFullScreenBar; m_FullScreen=FALSE; m_wndStatusBar.ShowWindow(SW_SHOWNORMAL); m_wndToolBar.ShowWindow(SW_SHOWNORMAL); m_wndSplitter.GetPane(0,0)->ShowWindow(SW_SHOWNORMAL); m_wndSplitter2.GetPane(1,0)->ShowWindow(SW_SHOWNORMAL); m_wndSplitter.SetColumnInfo(0,x,x1); m_wndSplitter2.SetRowInfo( 0,y,y1); WPNew = m_WPPrev; } SetWindowPlacement(&WPNew); } LRESULT CMainFrame::OnFullScreen(WPARAM wp,LPARAM lp) { OnScreenFull(); return 0; } void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { // TODO: Add your message handler code here and/or call default if(m_FullScreen) { lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height(); lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y; lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width(); lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x; } //CFrameWnd::OnGetMinMaxInfo(lpMMI); }